<?php

require_once ('html/htmlHelper.php');
require_once ('utility.php');

function getProjectForm($fy, $type, $result, $ppResult) {
    if (strcmp($type, "create") === 0) {
        if ($fy != null && strlen($fy) > 0) {
            $fy--;
            $startDate = "10/1/$fy";
            $fy++;
            $endDate = "10/1/$fy";
            $responsibleOrg = "NRL Reviewer";
            $responsibleOrgAddress = "NRL address??? Use same as performing org?";
            $responsiblePerson = "Dropdown??";
            $responsiblePersonPhone = "XXX-XXX-XXXX";
            $responsiblePersonEmail = "responsiblePerson@email.com";
            $responsiblePersonID = getPersonId($responsiblePerson, $responsiblePersonPhone, $responsiblePersonEmail);
        }
    } else if (strcmp($type, "edit") === 0 || strcmp($type, "view") === 0) {
        $row = mysqli_fetch_array($result);
        $startDate = getDatePickerFormat($row['startDate']);
        $endDate = getDatePickerFormat($row['endDate']);
        $title = $row['title'];
        $submitDate = getDatePickerFormat($row['submitDate']);
        $prevSummary = getDatePickerFormat($row['prevSummary']);
        $summaryType = $row['summaryType'];
        $summarySecurity = $row['summarySecurity'];
        $workSecurity = $row['workSecurity'];
        $levelOfSum = $row['levelOfSum'];
        $priProgramElement = $row['priProgramElement'];
        $priProjectNum = $row['priProjectNum'];
        $priTaskAreaNum = $row['priTaskAreaNum'];
        $priWorkUnitNum = $row['priWorkUnitNum'];
        $contrProgramElementB = $row['contrProgramElementB'];
        $contrProjectNumB = $row['contrProjectNumB'];
        $contrTaskAreaNumB = $row['contrTaskAreaNumB'];
        $contrWorkUnitNumB = $row['contrWorkUnitNumB'];
        $contrProgramElementC = $row['contrProgramElementC'];
        $contrProjectNumC = $row['contrProjectNumC'];
        $contrTaskAreaNumC = $row['contrTaskAreaNumC'];
        $contrWorkUnitNumC = $row['contrWorkUnitNumC'];
        $subjectArea = $row['subjectArea'];
        $fundingOrg = $row['fundingOrg'];
        $performanceMethod = $row['performanceMethod'];
        $status = $row['status'];

        if (strcmp($status, "piApproverSubmit") === 0 || strcmp($status, "approved") === 0 || strcmp($status, "approvalFinal") === 0) {
            $responsibleOrg = "PEO C4I/PMW 120";
            $responsibleOrgAddress = "PMW-120, 4301 Pacific Highway OT-01 San Diego, CA 92110-3127";
            $responsiblePerson = "Diallo Wallace";
            $responsiblePersonPhone = "858-537-xxxx";
            $responsiblePersonEmail = "responsiblePerson@email.com";
            $responsiblePersonID = getPersonId($responsiblePerson, $responsiblePersonPhone, $responsiblePersonEmail);
        } else {
            $responsibleOrg = "NRL Reviewer";
            $responsibleOrgAddress = "NRL address??? Use same as performing org?";
            $responsiblePerson = "Dropdown??";
            $responsiblePersonPhone = "XXX-XXX-XXXX";
            $responsiblePersonEmail = "responsiblePerson@email.com";
            $responsiblePersonID = getPersonId($responsiblePerson, $responsiblePersonPhone, $responsiblePersonEmail);
        }
        $performingOrg = $row['performingOrg'];
        $performingOrgAddress = $row['performingOrgAddress'];
        $technicalObjective = $row['technicalObjective'];
        $approach = $row['approach'];
        $progress = $row['progress'];
        $background = $row['background'];
        $application = $row['application'];
        $wbsId = $row['wbsId'];
        //get personnel stuff
        $projectID = $row['projectID'];
        $aiNameList = array();
        $aiPhoneList = array();
        $aiEmailList = array();
        while ($row = mysqli_fetch_array($ppResult)) {
            $role = $row['role'];
            if (strcmp($role, "pi") == 0) {
                $piID = $row['personID'];
                $piName = $row['name'];
                $piPhone = $row['phone'];
                $piEmail = $row['email'];
            } else if (strcmp($role, "ai") == 0) {
                array_push($aiNameList, $row['name']);
                array_push($aiPhoneList, $row['phone']);
                array_push($aiEmailList, $row['email']);
            }
        }
    }
    $colWidth = 100 / 8;
    if (strcmp($type, "view") == 0) {
        getFormLinePost("singleProjectForm", "editProjectController.php");
    } else {
        //getFormLinePostWithOnSubmit("createProjectForm", "projectSubmit.php", "validate1498(this)");
        getFormLinePostWithOnSubmit("createProjectForm", "projectController.php", "validate1498(this)");
    }
    echo '<table class="width100" cellspacing="1">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';
    echo '<col width="' . $colWidth . '%">';

    echo '  <tr width="100%">';
    echo '     <td class="form-title" colspan="4" rowspan="2">Research and Technology Research Summary</td>';
    echo '     <td class ="header" colspan="2">1. DATE OF SUMMARY</td>';
    echo '     <td class ="header" colspan="2">2. DATE PREVIOUS SUMMARY</td>';
    echo '  </tr>';
    echo ' <tr class="field">';
    echo '    <td class="black" colspan="2">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldDateOfSummary", NULL, NULL, NULL, "datepicker0");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldDateOfSummary", "98%", $submitDate, NULL, "datepicker0");
    } else {
        echo $submitDate;
    }
    echo '    </td>';
    echo '    <td class="black" colspan="2">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldDateOfPrevSummary", NULL, NULL, NULL, "datepicker1");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldDateOfPrevSummary", "98%", $prevSummary, NULL, "datepicker1");
    } else {
        echo $prevSummary;
    }
    echo '</td>';
    echo '</tr>';

    echo ' <tr class ="header">';
    echo '     <td class ="header" colspan="2">3. KIND OF SUMMARY</td>';
    echo '     <td class ="header" colspan="2">4. SUMMARY SECURITY</td>';
    echo '     <td class ="header" colspan="2">5. WORK SECURITY</td>';
    echo '     <td class ="header" colspan="2">6. LEVEL OF SUM</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldTypeOfSummary");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldTypeOfSummary", "98%", $summaryType);
    } else {
        echo $summaryType;
    }
    echo '    </td>';
    echo '    <td class="black" colspan="2">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldSummarySecurity", NULL, NULL, NULL, "Summary Security");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldSummarySecurity", "98%", $summarySecurity, NULL, "Summary Security");
    } else {
        echo $summarySecurity;
    }
    echo '    </td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldWorkSecurity", NULL, NULL, NULL, "Work Security");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldWorkSecurity", "98%", $workSecurity, NULL, "Work Security");
    } else {
        echo $workSecurity;
    }
    echo '    </td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldLevelOfSum");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldLevelOfSum", "98%", $levelOfSum);
    } else {
        echo $levelOfSum;
    }
    echo '    </td>';
    echo ' </tr>';

    echo ' <tr class ="header">';
    echo '     <td colspan="2">7. NO/CODES</td>';
    echo '     <td class ="header" colspan="2">PROGRAM ELEMENT</td>';
    echo '     <td class ="header">PROJECT NUMBER</td>';
    echo '     <td class ="header">TASK AREA NUMBER</td>';
    echo '     <td class ="header" colspan="2">WORK UNIT NUMBER</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '     <td class="black" colspan="2">a. PRIMARY</td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryProgramElement");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryProgramElement", "98%", $priProgramElement);
    } else {
        echo $priProgramElement;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryProjectNumber");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryProjectNumber", "98%", $priProjectNum);
    } else {
        echo $priProjectNum;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryTaskAreaNumber");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryTaskAreaNumber", "98%", $priTaskAreaNum);
    } else {
        echo $priTaskAreaNum;
    }
    echo '    </td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryWorkUnitNumber");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldPrimaryWorkUnitNumber", "98%", $priWorkUnitNum);
    } else {
        echo $priWorkUnitNum;
    }
    echo '    </td>';
    echo ' </tr>';

    echo ' <tr class="field">';
    echo '     <td class="black" colspan="2">b. CONTRIBUTING</td>';
    echo '    <td colspan="2" class="field">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrProgramElementB");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrProgramElementB", "98%", $contrProgramElementB);
    } else {
        echo $contrProgramElementB;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrProjectNumberB");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrProjectNumberB", "98%", $contrProjectNumB);
    } else {
        echo $contrProjectNumB;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrTaskAreaNumberB");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrTaskAreaNumberB", "98%", $contrTaskAreaNumB);
    } else {
        echo $contrTaskAreaNumB;
    }
    echo '    </td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrWorkUnitNumberB");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrWorkUnitNumberB", "98%", $contrWorkUnitNumB);
    } else {
        echo $contrWorkUnitNumB;
    }
    echo '    </td>';
    echo ' </tr>';

    echo ' <tr class="field">';
    echo '     <td class="black" colspan="2">c. CONTRIBUTING</td>';
    echo '    <td colspan="2" class="field">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrProgramElementC");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrProgramElementC", "98%", $contrProgramElementC);
    } else {
        echo $contrProgramElementC;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrProjectNumberC");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrProjectNumberC", "98%", $contrProjectNumC);
    } else {
        echo $contrProjectNumC;
    }
    echo '    </td>';
    echo '    <td class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrTaskAreaNumberC");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrTaskAreaNumberC", "98%", $contrTaskAreaNumC);
    } else {
        echo $contrTaskAreaNumC;
    }
    echo '    </td>';
    echo '    <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldContrWorkUnitNumberC");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldContrWorkUnitNumberC", "98%", $contrWorkUnitNumC);
    } else {
        echo $contrWorkUnitNumC;
    }
    echo '    </td>';
    echo ' </tr>';

    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="8">8. TITLE (Precede with Security Classification Code)</td>';
    echo ' </tr>';
    echo ' <tr width="100%" class="field">';
    echo '     <td colspan="8" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldTitle", "98%", NULL, NULL, "Title");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldTitle", "98%", $title, NULL, "Title");
    } else {
        echo $title;
    }
    echo '     </td>';
    echo ' </tr>';

    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="8">9. SUBJECT AREAS</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '     <td colspan="8" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldSubjectArea");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldSubjectArea", "98%", $subjectArea);
    } else {
        echo $subjectArea;
    }
    echo '     </td>';
    echo ' </tr>';

    echo ' <tr class ="header">';
    echo '     <td colspan="2">10. START DATE</td>';
    echo '     <td colspan="2">11. ESTIMATED COMPLETION DATE</td>';
    echo '     <td colspan="2">12. FUNDING ORGANIZATION</td>';
    echo '     <td colspan="2">13. PERFORMANCE METHOD</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '     <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldStartDate", NULL, $startDate, NULL, "datepicker2");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldStartDate", "98%", $startDate, NULL, "datepicker2");
    } else {
        echo $startDate;
    }
    echo '     </td>';
    echo '     <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldEndDate", NULL, $endDate, NULL, "datepicker3");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldEndDate", "98%", $endDate, NULL, "datepicker3");
    } else {
        echo $endDate;
    }
    echo '     </td>';
    echo '     <td colspan="2" class="black">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldFundingOrg", "98%");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldFundingOrg", "98%", $fundingOrg);
    } else {
        echo $fundingOrg;
    }
    echo '     </td>';
    echo '     <td class="black" colspan="2">';
    if (strcmp($type, "create") == 0) {
        echo getFormInputElement("text", "textFieldPerformMethod", "98%");
    } else if (strcmp($type, "edit") == 0) {
        echo getFormInputElement("text", "textFieldPerformMethod", "98%", $performanceMethod);
    } else {
        echo $performanceMethod;
    }
    echo '     </td>';
    echo ' </tr>';

    echo ' <tr class ="header">';
    echo '     <td colspan="4">14. RESPONSIBLE DOD ORGANIZATION</td>';
    echo '     <td colspan="4">15. PERFORMING ORGANIZATION</td>';
    echo ' </tr>';
    echo ' <tr class ="header">';
    echo '     <td class="form-title" colspan="4">'.$responsibleOrg.'</td>';
    if (strcmp($type, "view") === 0) {
        echo '     <td class="form-title" colspan="4">' . $performingOrg . '</td>';
    } else {
        echo '<td class="form-title" colspan="4"> Performing Org: ';
        if (strcmp($type, "edit") === 0) {
            getFormInputElement('text', 'performingOrgTextField', "98%", $performingOrg);
        } else {
            getFormInputElement('text', 'performingOrgTextField', "98%");
        }
        echo '</td>';
    }
    echo ' </tr>';
    echo ' <tr class ="header">';
    echo '     <td class="form-title" colspan="4">'.$responsibleOrgAddress.'</td>';
    if (strcmp($type, "view") === 0) {
        echo '     <td class="form-title" colspan="4">' . $performingOrgAddress . '</td>';
    } else {
        echo '<td class="form-title" colspan="4"> Address: ';
        if (strcmp($type, "edit") === 0) {
            getFormInputElement('text', 'performingOrgAddressTextField', "98%", $performingOrgAddress);
        } else {
            getFormInputElement('text', 'performingOrgAddressTextField', "98%");
        }
        echo '</td>';
    }
    echo ' </tr>';
//    echo ' <tr class ="header">';
//    echo '     <td class="field">Responsible Individual</td><td class="field">Phone</td><td colspan="2" class="field">Email</td>';
//    echo '     <td class="field">Principal Investigator</td><td class="field">Phone</td><td colspan="2" class="field">Email</td>';
//    echo ' </tr>';
    echo ' <tr class ="header">';
    echo '     <td class="form-title">'.$responsiblePerson.'</td>';
    echo '     <td class="form-title">'.$responsiblePersonPhone.'</td>';
    echo '     <td class="form-title" colspan="2">'.$responsiblePersonPhone.'</td>';
    echo '     <td class="form-title">';
//    if (strcmp($type, "create") == 0) {
//        //echo getTwoArgDropDown(getPrincipalInvestigators(), "piDropdown");
//        getGenericDropdownMenu(getPrincipalInvestigators(), "piDropdown",NULL,false);
//    } else if (strcmp($type, "edit") == 0) {
//        //getTwoArgDropDownWithSelection(getPrincipalInvestigators(), "piDropdown", $piID);
//        getGenericDropdownMenu(getPrincipalInvestigators(), "piDropdown",NULL,false,NULL,"piDropdown",$piID);
//    }
    if (strcmp($type, "create") == 0) {
        echo "Name: ";
        getFormInputElement('text', 'piNameTextField', "98%", NULL, NULL, "PI Name");
    } else if (strcmp($type, "edit") == 0) {
        echo "Name: ";
        getFormInputElement('text', 'piNameTextField', "98%", $piName, NULL, "PI Name");
    } else {
        echo $piName;
    }

    echo '</td>';
    echo '     <td class="form-title" id="aiPhoneBox">';
    if (strcmp($type, "create") == 0) {
        echo "Phone: ";
        getFormInputElement('text', 'piPhoneTextField', "98%", NULL, NULL, "PI Phone");
    } else if (strcmp($type, "edit") == 0) {
        echo "Phone: ";
        getFormInputElement('text', 'piPhoneTextField', "98%", $piPhone, NULL, "PI Phone");
    } else {
        echo $piPhone;
    }
    echo '</td>';
    echo '     <td class="form-title" colspan="2" id="aiEmailBox">';
    if (strcmp($type, "create") == 0) {
        echo "Email: ";
        getFormInputElement('text', 'piEmailTextField', "98%", NULL, NULL, "PI Email");
    } else if (strcmp($type, "edit") == 0) {
        echo "Email: ";
        getFormInputElement('text', 'piEmailTextField', "98%", $piEmail, NULL, "PI Email");
    } else {
        echo $piEmail;
    }
    echo '</td>';
    echo ' <tr>';

    //ASSOCIATE INVESTIGATORS
    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="4">16. GENERAL USE</td>';
    echo '     <td colspan="4">17. ASSOCIATE INVESTIGATOR(S)</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo ' <td class="black">APPLICATION</td>';
    echo '     <td colspan="3" class="black">';
    $array = array("MILITARY", "CIVILIAN");
    if (strcmp($type, "create") == 0) {
        echo getDropDownMenu($array, "appDropdown");
    } else if (strcmp($type, "edit") == 0) {
        getDropDownWithSelection($array, "appDropdown", $application);
    } else {
        echo $application;
    }
    if (strcmp($type, "view") !== 0) {
        echo ' <td class="black">Name</td><td class="black">Phone</td><td colspan="2" class="black">Email</td>';
    } else {
        echo ' <td colspan="4"></td>';
    }
    echo '</tr>';

    if (strcmp($type, "edit") === 0 || strcmp($type, "create") === 0) {
        echo '<tr>';
        echo '     <td colspan="4" class="field"></td>';
        echo '     <td class="field">';
        echo getFormInputElement("text", "textFieldAiName", "97%", NULL, NULL, "aiName");
        echo '     </td>';
        echo '     <td class="field">';
        echo getFormInputElement("text", "textFieldAiPhone", "97%", NULL, NULL, "aiPhone");
        echo '     </td>';
        echo '     <td class="field">';
        echo getFormInputElement("text", "textFieldAiEmail", "97%", NULL, NULL, "aiEmail");
        echo '     </td>';
        echo '     <td class="field">';
        getFormInputElement("button", "addButton", NULL, 'Add', "addAiRow()", NULL);
        echo '     </td>';
        echo ' </tr>';
    }


    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="4" class="field"></td>';
    echo '     <td class="field" colspan="4">';
    echo '       <table class="width100" cellspacing="1" id="aiTable">';
    //echo '       <col width="20%"><col width="20%"><col width="30%"><col width="10%">';
    echo '        <tr class ="header">';
    echo '          <td>Name</td>';
    echo '          <td>Phone</td>';
    echo '          <td>Email</td>';
    echo '          <td></td>';
    echo '        </tr>';
    if (strcmp($type, "edit") === 0 || strcmp($type, "view") === 0) {
        for ($i = 0; $i < sizeof($aiNameList); $i++) {
            echo '        <tr id="row' . $i . '" class="field">';
            echo '     <td class="black">';
            echo '       <input type="hidden" id="nameField' . $i . '" name="nameField' . $i . '" value="' . $aiNameList[$i] . '">' . $aiNameList[$i] . '';
            echo '     </td>';
            echo '     <td class="black">';
            echo '       <input type="hidden" id="phoneField' . $i . '" name="phoneField' . $i . '" value="' . $aiPhoneList[$i] . '">' . $aiPhoneList[$i] . '';
            echo '     </td>';
            echo '     <td class="black">';
            echo '       <input type="hidden" id="emailField' . $i . '" name="emailField' . $i . '" value="' . $aiEmailList[$i] . '">' . $aiEmailList[$i] . '';
            echo '     </td>';
            echo '     <td class="field">';
            if (strcmp($type, "edit") == 0) {
                getFormInputElement("button", "$i", NULL, 'Remove', "removeAiRow(this.name)", NULL);
            }
            echo '</td>';
            echo '        </tr>';
        }
    }
    //echo '        </tr>';
    echo getCloseTag("table");
    echo '     </td>';
    //echo '     <td class="field"></td>';
    echo ' </tr>';

    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="4">18. TECHNICAL OBJECTIVE</td>';
    echo '     <td colspan="4">19. APPROACH</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '     <td colspan="4" class="black">';
    if (strcmp($type, "create") == 0) {
        getTextArea("technicalObjectiveTextArea", 500);
    } else if (strcmp($type, "view") == 0) {
        echo $technicalObjective;
    } else {
        getTextArea("technicalObjectiveTextArea", 500, $technicalObjective);
    }
    echo '     </td>';
    echo '     <td colspan="4" class="black">';
    if (strcmp($type, "create") == 0) {
        getTextArea("approachTextArea", 500);
    } else if (strcmp($type, "edit") == 0) {
        getTextArea("approachTextArea", 500, $approach);
    } else {
        echo $approach;
    }
    echo '     </td>';
    echo ' <tr width="100%" class ="header">';
    echo '     <td colspan="4">20. PROGRESS (If applicable)</td>';
    echo '     <td colspan="4">21. BACKGROUND</td>';
    echo ' </tr>';
    echo ' <tr class="field">';
    echo '     <td colspan="4" class="black">';
    if (strcmp($type, "edit") == 0) {
        getTextArea("progressTextArea", 500, $progress);
    } else if (strcmp($type, "create") == 0) {
        getTextArea("progressTextArea", 500);
    } else {
        echo $progress;
    }
    echo '     </td>';
    echo '     <td colspan="4" class="black">';
    if (strcmp($type, "edit") == 0) {
        getTextArea("backgroundTextArea", 500, $background);
    } else if (strcmp($type, "create") == 0) {
        getTextArea("backgroundTextArea", 500);
    } else {
        echo $background;
    }
    echo '     </td>';
    echo ' </tr>';

    //Leave in for testing. This should be created when the project is approved?
    echo '<tr><td colspan="8">Should WBS be entered by PI??? For entering pilot 1498 projects the following fields are available</td></tr>';
    if ($result) {
        getWbsRow($type, $wbsId);
    } else {
        getWbsRow($type);
    }

    //submit/edit button
    if ($result) {
        getProjectButtonOptions($type, $projectID);
    } else {
        getProjectButtonOptions($type);
    }
    echo '</table>';
    echo '</form>';
}



?>
